export default {
    state: {
        times: new Date(),
        name: "wayne"
    },
    mutations: {
        updateName(state, payload) {
            // state.name = 'kobe'
            state.name = payload.name
        }
    },
    actions: {
        aUpdateName(content) {
            console.log(content)
            // content包含dispath，commit，getters，state，rootGetters，rootState
            // 也可以用 对象的解构 的方式写 content
            setTimeout(() => {
                content.commit({
                    type: 'updateName',
                    name: 'HanMeimei'
                })
            }, 2000)
        }
    },
    getters: {
        fullName(state) {
            return state.name + ' fullName'
        },
        fullName2(state, getters) {
            return getters.fullName + " 123"
        },
        fullName3(state, getters, rootState) {
            // rootState可以拿到根store的state数据
            return getters.fullName + " 123" + rootState.counter
        }
    }
}